//
//  InvoicesCell.m
//  KurtulusLaw
//
//  Created by phuc phuc on 12/1/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "InvoicesCell.h"
#import "KInvoicesDTO.h"
@implementation InvoicesCell
@synthesize imgFileButton = _imgFile;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setSearchFileDTO:(KBaseSearchFileDTO *)searchFile {

    
	[super setSearchFileDTO:searchFile];
	
	if ([searchFile isKindOfClass:[KInvoicesDTO class]]) {
		KInvoicesDTO *invoicesFile = (KInvoicesDTO *) searchFile;
		
		if (invoicesFile.imgFile && [invoicesFile.imgFile length] > 0) {
			[self.imgFileButton setHidden:NO];
			self.tag = eFileTypeIMG;
		} else {
			[self.imgFileButton setHidden:YES];
		}
        		
    }
}


- (IBAction)touchUpInsideImgFileButton:(id)sender {
	if (self.delegate) {
		KInvoicesDTO *invoicesDTO = (KInvoicesDTO *)self.searchFileDTO;
		
		[self.delegate searchFileCell:self clickDocumentFile:self.imgFileButton.tag relativePath:[invoicesDTO.imgFile copy]];
	}
}
@end
